﻿Public Class frmTheLoaiPhim

    Private Sub frmTheLoaiPhim_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox_Load()
        cmbTheLoaiPhim.Text = "Hành động"
    End Sub
    Private Sub ComboBox_Load()
        Dim bus As PhimBUS = New PhimBUS()
        cmbTenPhim.DataSource = bus.GetTable("select * from PHIM")
        cmbTenPhim.DisplayMember = "TenPhim"
        cmbTenPhim.ValueMember = "TenPhim"
    End Sub

    Private Sub btnSetTheLoaiPhim_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetTheLoaiPhim.Click
        Dim p As TheLoaiPhimDTO = New TheLoaiPhimDTO()
        Dim bus As TheLoaiPhimBUS = New TheLoaiPhimBUS()
        Dim kt As String = "select * from THELOAIPHIM where TenPhim='" + cmbTenPhim.SelectedValue.ToString() + "' and TenTheLoai = '" + cmbTheLoaiPhim.Text + "'"
        Dim dt = New DataTable
        dt = bus.GetTable(kt)
        If (dt.Rows.Count = 0) Then

            p.TenPhim = cmbTenPhim.SelectedValue.ToString()
            p.TenTheLoai = cmbTheLoaiPhim.Text
            bus.Insert(p)
            MessageBox.Show("Thành công", "Thông báo")
        Else
            MessageBox.Show("Đã có", "Thông báo")
        End If
    End Sub
End Class